import 'package:flutter/material.dart';

import 'package:flutter_swiper/flutter_swiper.dart';

class SwiperConstructor extends StatefulWidget {
  
  Map swiper = {
    'autoplay': false,
    'list': []
  };
  SwiperConstructor(this.swiper, {Key key}) : super(key: key);

  @override
  _SwiperConstructorState createState() => _SwiperConstructorState(this.swiper);
}

class _SwiperConstructorState extends State<SwiperConstructor> {

  Map swiper = {};
  _SwiperConstructorState(this.swiper);

  @override
  Widget build(BuildContext context) {
    return Swiper(
      itemBuilder: (BuildContext context, int i){
        return ClipRRect(
          borderRadius: BorderRadius.circular(10),
          child: Image.network(
            this.swiper['list'][i]['url'],
            fit: BoxFit.cover,
          )
        );
      },
      itemCount: this.swiper['list'].length,
      viewportFraction: 0.88,
      scale: 0.92,
      autoplay: this.swiper['autoplay'],
      duration: this.swiper['duration'] == null ? 300 : this.swiper['duration'] 
    );
  }
}